#include <iostream>

const int N = 3e6 + 5;
const int P = 998244353;

int m, a, b;
long long n;

int main() {
	std::freopen("clown.in", "r", stdin);
	std::freopen("clown.out", "w", stdout);

	std::cin >> m;
	n = 1;
	while(m--) {
		int x; std::cin >> x;
		n *= x;
	}
	std::cin >> a >> b;
	if(n == 3) {
		int ans = 1ll * a * a % P * a % P * b % P * b % P * b % P;
		ans = (ans - 1ll * a * b) % P;
		ans = (ans - 3ll * a * (a - 1) % P * b % P * b % P - 3ll * a * b % P * (b - 1) % P) % P;
		std::cout << (ans + P) % P << "\n";
	}

	return 0;
}
